import Types from '../actionTypes';

let initState = {
  specsSelect: '',  // 所选中的code
  specsIsSelect: '', // 是否选中
  activeKey: null, // 折叠面板的所选的code
  activeTitle: null,// 折叠面板的title
  specsData: null
};

export default (state = initState, action) => {
  const newState = JSON.parse(JSON.stringify(state));
  switch (action.type) {
    case Types.SPECS_SELECT:
      newState.specsSelect = action.value;
      return newState;
    case Types.SPECS_IS_SELECT:
      newState.specsIsSelect = action.value;
      return newState;
    case Types.GET_SPECSLIBRARY_INFO:
      newState.specsData = action.data;
      return newState;
    case Types.ACTIVE_KEY:
      newState.activeKey = action.value;
      return newState;
    case Types.ACTIVE_TITLE:
      newState.activeTitle = action.value;
      return newState;
    default:
      console.log('Types no match in specsLibrary.js ....');
  }
  return state;
}
